package com.pushway.demo.pojo;

import io.prometheus.client.Collector;
import io.prometheus.client.Summary;

import java.util.List;

public class SummaryPushItem extends PushItem {

    private String name;

    private String helpMsg;

    private List<String> labelNames;

    private Summary summary;

    protected SummaryPushItem(String instance, String job) {
        super(instance, job);
    }
    public SummaryPushItem(String instance, String job, String name, String helpMsg, List<String> labelNames) {
        this(instance, job);
        this.name = name;
        this.helpMsg = helpMsg;
        this.labelNames = labelNames;
        summary = Summary.build()
                .name(name)
                .help(helpMsg)
                .labelNames(this.labelNames.toArray(new String[0]))
                .register();
    }

    /**
     * 标记元素
     * @param labelValues
     * @return
     */
    public Summary.Child labels(String... labelValues) {
        return summary.labels(labelValues);
    }
    @Override
    public Collector getCollector() {
        return summary;
    }
}
